<?php
declare (strict_types=1);

namespace app\admin\validates;

use think\Validate;

/**
 * Menu验证器
 */
class MenuValidate extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [
        'id' => 'require|number',
        'parent_id' => 'require|number',
        'menu_name' => 'chsDash|max:50',
        'menu_type' => 'chsDash|max:50',
        'orderby' => 'require|number',
        'path' => 'max:255',
        'component' => 'max:255',
        'query' => 'max:255',
        'rule' => 'max:255',
        'is_frame' => 'require|number',
        'status' => 'require|number',
        'visible' => 'require|number',
        'icon' => 'max:255',
        'remark' => 'max:255',
    ];

    /**
     * 验证字段描述
     * @var string[]
     */
    protected $field = [
        'id' => 'ID',
        'parent_id' => '上级ID',
        'menu_name' => '菜单名称',
        'menu_type' => '菜单类型',
        'orderby' => '排序',
        'path' => '前端路由地址',
        'component' => '前端组件路径',
        'query' => '前端路由参数',
        'rule' => '后端权限标识',
        'is_frame' => '是否为外链',
        'status' => '菜单状态',
        'visible' => '菜单状态',
        'icon' => '菜单图标',
        'remark' => '备注',
    ];

    /**
     * 验证场景
     * @var array
     */
    protected $scene = [
        'add_m' => ['parent_id', 'icon', 'menu_name', 'menu_type', 'orderby', 'rule'],
        'add_c' => ['parent_id', 'icon', 'menu_name', 'menu_type', 'orderby', 'rule', 'component', 'rule', 'query'],
        'add_f' => ['parent_id', 'menu_name', 'menu_type', 'orderby', 'rule'],
        'edit_m' => ['id', 'parent_id', 'icon', 'menu_name', 'menu_type', 'orderby', 'rule'],
        'edit_c' => ['id', 'parent_id', 'icon', 'menu_name', 'menu_type', 'orderby', 'rule', 'component', 'rule', 'query'],
        'edit_f' => ['id', 'parent_id', 'menu_name', 'menu_type', 'orderby', 'rule'],
    ];

}